package com.dgshanger.sanhxiaofeisc.ui.home.activity

import cn.jzvd.JZVideoPlayer
import cn.jzvd.JZVideoPlayerStandard
import com.dgshanger.sanhxiaofeisc.R
import com.dgshanger.sanhxiaofeisc.common.Constants
import com.dgshanger.sanhxiaofeisc.ui.home.utils.ImageLoader
import com.xx.baseuilibrary.mvp.BaseMvpViewActivity
import kotlinx.android.synthetic.main.activity_home_video.*



/**
 * Created by JacobHHH on 2018/4/26.
 * 首页视频
 */
class HomeVideoActivity : BaseMvpViewActivity(){

    private lateinit var mVideoUrl : String

    override fun getActivityLayoutId(): Int = R.layout.activity_home_video

    override fun initData() {
        mVideoUrl=intent.getStringExtra("videoUrl")
        val title = intent.getStringExtra("title")
        tv_video_title.text=title
        jz_video.setUp(ImageLoader.getUrl(mVideoUrl)
                , JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL)
        jz_video.backButton.setOnClickListener { finish() }



    }

    override fun initEvent() {
    }

    override fun onBackPressed() {
        if (JZVideoPlayer.backPress()) {
            return
        }
        super.onBackPressed()
    }

    override fun onPause() {
        super.onPause()
        JZVideoPlayer.releaseAllVideos()
    }

    override fun onDestroy() {
        super.onDestroy()
        JZVideoPlayer.clearSavedProgress(mContext,ImageLoader.getUrl(mVideoUrl))
    }
}